package com.xxx.study.designmodel.d单例模式;

/**
 * 饿汉式 单例
 * 空间换时间
 */
public class HungrySingleton {
    private String content;

    public String getContent() {
        return content;
    }

    private static HungrySingleton singleton = new HungrySingleton("饿汉式单例");

    /**
     * 私有化构造方法
     * @param content
     */
    private HungrySingleton(String content) {
        this.content = content;
    }

    /**
     * 类加载时，提前创建好
     * @return
     */
    public static HungrySingleton getInstance() {
        try{
            Thread.sleep(1);
        } catch (Exception e){

        }
        return singleton;
    }
}
